import tkinter as tk
root = tk.Tk()
root.title('my tkinter')
root.geometry('200x200')
l = tk.Label(root,text='',bg='yellow',width=20)
l.pack()
counter = 0
def do_job1():
    global counter
    l.config(bg='blue',text='new'+str(counter))
    counter+=1


m_1 = tk.Menu(root)
m1 = tk.Menu(m_1,tearoff=0)
m_1.add_cascade(label='m5',menu=m1)
m1.add_command(label='New',command=do_job1)
m1.add_command(label='open',command=do_job1)
m1.add_separator()
m1.add_command(label='exit',command=root.quit)

m2 = tk.Menu(m_1,tearoff=0)
m_1.add_cascade(label='m2',menu=m2)
m2.add_command(label='d',command=do_job1)
m2.add_command(label='j',command=do_job1)
m2.add_separator()
m2.add_command(label='y',command=root.quit)

a1 = tk.Menu(m2,tearoff=0)
m2.add_cascade(label='分支',menu=a1)
a1.add_command(label='d',command=do_job1)



root.config(menu=m_1)

root.mainloop()